package cn.tedu.batch.sink

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.core.fs.FileSystem.WriteMode

/**
 * @author Amos
 * @date 2022/5/22
 */

object BatchSinkFile {
  def main(args: Array[String]): Unit = {
    val env = ExecutionEnvironment.getExecutionEnvironment
    import org.apache.flink.api.scala._
    val stu: DataSet[(Int, String, Double)] = env.fromElements(
      (19, "zhangsan", 178.8),
      (17, "lisi", 168.8),
      (18, "wangwu", 184.8),
      (21, "zhaoliu", 164.8)
    )

    // 1. 将数据保存到本地
    stu.writeAsText("FLINKSCALA/data/outout/002",WriteMode.OVERWRITE)

    // 2. 将数据写入到hdfs
    stu.writeAsText("hdfs://hadoop01:8020/test/output/007",WriteMode.OVERWRITE)
    env.execute()

  }

}
